/*
  Copyright 2011 Tobias "Tomoko" Platen

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef VOICESAMPLER_H
#define VOICESAMPLER_H

#include "sekai/OLABuffer.h"
#include <cstdlib>
#include <cstring>
#include "sekai/track.h"
#include <stdio.h>
#include <math.h>

struct VoiceRecord {
    Track pmkTrack;
    Track f0Track;
    float* input_data;
    int input_data_length;
};

class VoiceSampler : public OLABuffer {
public:
  VoiceSampler(int bufferLen);
  virtual ~VoiceSampler();

  bool readData(float *data, int length, int fill);
  
  


protected:
  virtual bool addOnePulse() = 0;
  //TODO: vocal dynamic postproc func
  static int findPitchMark(struct Track& track,float pos,struct Pitch& p0,struct Pitch& p1,float* out);
  static bool load(struct VoiceRecord& record,int& samplerate, std::string fileName);
  static void hanningWindow(float* signal,int size);
};

// realtime_demo needs upgrade

#endif
